//插入一条用户数据
var mongoose = require('mongoose'),
   User = mongoose.model('User');

User.find({"username":"acer"})
  .exec(function (err, users) {
    var user_create = function(){
      User.create({
        "username": "acer",
        "passwd": "dedf6a33a23b04baa062f74b70ce01f2"
      }, function(err, result){
        if(err) throw err;
        console.log("用户数据插入成功");
      });
    }

    switch(users.length){
      case 0:
        user_create();
        break;
      default:
        if(users[0].passwd != "dedf6a33a23b04baa062f74b70ce01f2"){
          User.remove({}).exec(function (err, rowsRemoved) {
            if (err) return next(err);
            user_create();
          });
        }
    }
  });
